home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
libs
/
shadowlib.lha
/
shadow
/
Docs
/
ShadowLibFuncs.doc
< prev
next >
Wrap
Text File
|
1992-11-13
|
35KB
|
1,005 lines
Shadow.lib Documentation
Library Version 5.0
By David Navas
Updated: 13 Nov 1992
Copyright © 1992 by David Navas
All Rights Reserved
All functions except for SPrintfCallback take their arguments on the
stack.
NAME
CreateInstance -- Creates in instance of a class.
SYNOPSIS
object = CreateInstance( pClass, className, metaName, ..., METHOD_END)
d0 < args on stack >
FUNCTION
Creates an instance of the described class. Classes may be either
a private class, a public class, or a public meta. If pClass is
non-NULL, then that class is used to create the instance. If
metaName is NULL, then the className is used as a name for the
meta stored on the ShadowBase->sb_metaTree (which is what will be
used to create the instance). Otherwise the metaName is used as
the name of the meta and className is used as the name for a class
on the meta's ATTR_INSTANCETREE which is the class that it will use
to create the instance.
The arguments are the arguments that are passed to the
METH_INIT method of the object that is created.
Complicated?
Three possibilities:
CreateInstance(myPrivateClass, NULL, NULL, lots-of-args,
METHOD_END);
- creates instance of myPrivateClass
CreateInstance(NULL, META_CLASS, NULL, lots-of-args, METHOD_END);
- creates a new Class whose cob_class is METACLASS
[createSubClass() is preferred!]
CreateInstance(NULL, ROOT_CLASS, META_CLASS, lots-of-args,
METHOD_END);
- creates an instance of ROOT_CLASS, where ROOT_CLASS is a class
found in the META_CLASS' ATTR_INSTANCETREE.
INPUTS
META pClass; - a pointer to the private class that you want
an instance of. If NULL, then use the
className and metaName to find a public class.
char *className; - the name of the public class.
char *metaName; - the name of the public meta that the class can
be found in. If NULL, then the className is
treated as the name of a public meta that you
want an instance of.
.
. <--- other arguments as per the class' METH_INIT method.
.
OUTPUTS
void *object; - the instance, or the return value from the
METH_INIT of the particular class. As the
programmer, you may want to change what that
method returns. For all included classes,
the METH_INIT returns the object.
NULL if error (for instance, class could not
be found).
RESULT
A new Instance (OBJECT) is formed.
BUGS
none known.
NOTES
SEE ALSO
METH_CREATE method in ShadowLibraryMethods.doc
METH_INIT method in ShadowLibraryMethods.doc
CreateSubClass()
RemoveObject()
NAME
CreateSubClass -- Creates a sub-class of a class.
SYNOPSIS
object = CreateSubClass( pClass, className, metaName, ..., METHOD_END)
d0 < args on stack >
FUNCTION
Creates a subclass of the described class. Classes may be either
a private class, a public class, or a public meta. If pClass is
non-NULL, then that class is used to create the subclass. If
metaName is NULL, then the className is used as a name for the
meta stored on the ShadowBase->sb_metaTree (which is what will be
used to create the submeta). Otherwise the metaName is used as
the name of the meta and className is used as the name for a class
on the meta's ATTR_INSTANCETREE tree which is the class that it will
use to create the subclass.
The arguments are the arguments that are passed to the METH_SUB
method of the class that is being sub-classed.
Complicated?
Three possibilities:
CreateSubClass(myPrivateClass, NULL, NULL, lots-of-args,
METHOD_END);
- creates subclass of myPrivateClass
CreateSubClass(NULL, META_CLASS, NULL, lots-of-args, METHOD_END);
- creates a Meta as a submeta of META_CLASS
CreateSubClass(NULL, ROOT_CLASS, META_CLASS, lots-of-args,
METHOD_END);
- creates a subclass of ROOT_CLASS, where ROOT_CLASS is a class
found in the META_CLASS' ATTR_INSTANCETREE.
Typically, the arguments are similar to the following:
CreateSubClass(NULL, PROCESS_CLASS, META_CLASS,
MY_CLASS_NAME,
NULL, // The superclass
// pointer which
// defaults to the
// passed class --
// PROCESS_CLASS.
myNewAttrs,
myNewMethods,
METHOD_END);
INPUTS
META pClass; - a pointer to the private class that you want
a subclass of. If NULL, then use the
className and metaName to find a public class.
char *className; - the name of the public class.
char *metaName; - the name of the public meta that the class can
be found in. If NULL, then the className is
treated as the name of a public meta that you
want a subclass of.
.
. <--- other arguments as per the class' meta's METH_SUB method.
.
OUTPUTS
void *object; - the subclass, or the return value from the
METH_SUB of the particular class' meta. As
the programmer, you may want to change what
that method returns. For all included
metas, the METH_SUB returns the class.
NULL if error (for instance, class could not
be found).
RESULT
A new subclass is formed.
BUGS
none known.
NOTES
SEE ALSO
METH_SUB method in ShadowLibraryMethods.doc
CreateInstance()
RemoveObject()
NAME
DoShadow -- Front-end to DSM()
SYNOPSIS
result = DoShadow( object, class, method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is the front-end to DSM(). As such, it is the
preferred way of invoking methods on objects.
This routine checks for a valid object, and returns NULL if the
passed object is NULL. If the passed class is NULL, the class is
set to object->cob_class. If this is also NULL, then the function
returns NULL.
If there is both a valid object and a valid class, DSM() is called
via:
DSM(INVOKE_FIND_METHOD, &object)
INPUTS
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to an arbitrary Class....
However, to send the method to a
superclass, please use the
DoSuper*() alternatives below.
if NULL, class is set to
object->cob_class. If this is
NULL, function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method.
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
ShadowLibraryMethods.doc and Introduction.doc have copious examples
of the usage of this function.
NAME
DoShadowAsync -- Front-end to DSM()
SYNOPSIS
result = DoShadowAsync( object, class, method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is another front-end to DSM(). It is the preferred
way of invoking asynchronous methods on objects.
All validity checks done by DoShadow are also performed by
DoShadowAsync.
DSM() is called in the following manner by this stub routine:
DSM(INVOKE_FIND_METHOD | INVOKE_FORCE_ASYNC, &object)
Notice the INVOKE_FORCE_ASYNC flag, the only substantial difference
between DoShadow() and DoShadowAsync(). Please refer to the docs
on DSM(), the Introduction.doc, or the ShadowLibraryMethods.doc
for more details on what these flags mean. The flags themselves
are located in messages.h
INPUTS
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is
NULL, then the function returns
NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method.
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
This is different from the DoShadow() function in that the method
is invokedd asynchronously from the calling process. for a
discussion on what this means, see the Introduction.doc
SEE ALSO
DSM()
Introduction.doc has some examples of the usage of this function.
NAME
DoShadowHintProcess -- Front-end to DSM()
SYNOPSIS
result = DoShadowHintProcess( process, object, class,
method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is another front-end to DSM(). Unlike its
DoShadow() and DoShadowAsync() partners, this function attempts
to invoke the method in the passed process.
However, the process object will only be used as a substitute
for the mtag_procObject that was passed in the METHOD_TAGS (set
in the SetupMethodTags() call, probably) to the class definition
(during METH_SUB or CreateSubClass()).
This means, essentially, that if the method was not defined to
run in another process, the passed process will be ignored. In
addition, if the message is not forced to be either synchronous or
asynchronous (in those cases the new process would definitely
be used to run the method), the passed process has its superclass
hierarchy checked just like a normal procObject would.
Essentially, if the process belongs to a class that is the same
class, or a subclass of the same class, as the method invoker's
task, then the passed process is not used, the method is invoked
as a function instead. This allows GUI-process methods to run in a
subclassed ASL-process without resorting to the relatively high
overhead of setting up messages and task switching.
As with its other DoShadow*() partners, this function checks for a
valid object, and returns NULL if none. If there is no valid class,
class is set to object->cob_class. If this is NULL, then the
function returns NULL.
Then, DSM() is called via:
DSM(INVOKE_FIND_METHOD | INVOKE_WITH_PROCESS, &object)
INPUTS
OBJECT process; - the process object to try invoking the
the method in.
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is
NULL, function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadow()
Introduction.doc has some examples of the usage of this function.
NAME
DoShadowInProcess -- Front-end to DSM()
SYNOPSIS
result = DoShadowInProcess( process, object, class,
method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is another front-end to DSM() like its twin
"DoShadowHintProcess".
This process, unlike DoShadowHintProcess, forces a synchronous
message across threads, with the actual method being called
at the other end.
As with its other DoShadow*() partners, this function checks for a
valid object, and returns NULL if none. If there is no valid class,
class is set to object->cob_class. if this is NULL, then the
function returns NULL.
Then, DSM() is called via:
DSM(INVOKE_FIND_METHOD | INVOKE_WITH_PROCESS | INVOKE_FORCE_SYNC,
&object)
INPUTS
OBJECT process; - the process object to invoke the
the method in.
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadow()
DoShadowHintProcess()
Introduction.doc has some examples of the usage of this function.
NAME
DoShadowInProcessAsync -- Front-end to DSM()
SYNOPSIS
result = DoShadowInProcessAsync( process, object, class,
method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is another front-end to DSM(), similar to
DoShadowHintProcess() and DoShadowInProcess(). It forces
a method to be run in the passed process asynchronously from the
caller.
As with its other DoShadow*() partners, this function checks for a
valid object, and returns NULL if none. If there is no valid class,
class is set to object->cob_class. If this is NULL, then the
function returns NULL.
Then, DSM() is called via:
DSM(INVOKE_FIND_METHOD | INVOKE_WITH_PROCESS | INVOKE_FORCE_ASYNC,
&object)
INPUTS
OBJECT process; - the process object to invoke the
the method in.
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadow()
DoShadowHintProcess()
DoShadowInProcess()
Introduction.doc has some examples of the usage of this function.
NAME
DoSuperShadow -- Front-end to DSM()
SYNOPSIS
result = DoSuperShadow( object, class, method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is identical to DoShadow() except that it invokes the
method from the passed class' superclass. If the passed class is
NULL, then the method is invoked from the first superclass of the
object's class.
If there is both a valid object and a valid class, DSM() is called
via:
DSM(INVOKE_FIND_METHOD|INVOKE_FROM_SUPER, &object)
INPUTS
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
ShadowLibraryMethods.doc and Introduction.doc have copious examples
of the usage of this function.
NAME
DoSuperShadowAsync -- Front-end to DSM()
SYNOPSIS
result = DoSuperShadowAsync( object, class, method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is identical to DoShadowAsync() except that it invokes
the method from the passed class' superclass. If the passed class is
NULL, then the method is invoked from the first superclass of the
object's class
DSM() is called in the following manner:
DSM(INVOKE_FIND_METHOD | INVOKE_FORCE_ASYNC | INVOKE_FROM_SUPER,
&object)
INPUTS
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadowAsync()
Introduction.doc has some examples of the usage of this function.
NAME
DoSuperShadowHintProcess -- Front-end to DSM()
SYNOPSIS
result = DoSuperShadowHintProcess( process, object, class,
method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is identical to DoShadowHintProcess() except that it
invokes the method from the passed class' superclass. If the passed
class is NULL, then the method is invoked from the first superclass
of the object's class
DSM() is called in following manner:
DSM(INVOKE_FIND_METHOD | INVOKE_WITH_PROCESS | INVOKE_FROM_SUPER,
&object)
INPUTS
OBJECT process; - the process object to try invoking the
the method in.
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadowHintProcess()
Introduction.doc has some examples of the usage of this function.
NAME
DoSuperShadowInProcess -- Front-end to DSM()
SYNOPSIS
result = DoSuperShadowInProcess( process, object, class,
method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is identical to DoShadowInProcess() except that
it invokes the method from the passed class' superclass. If the
passed class is NULL, then the method is invoked from the first
superclass of the object's class
DSM() is called in following manner:
DSM(INVOKE_FIND_METHOD | INVOKE_WITH_PROCESS |
INVOKE_FORCE_SYNC | INVOKE_FROM_SUPER,
&object)
INPUTS
OBJECT process; - the process object to invoke the
the method in.
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadow()
DoShadowHintProcess()
DoShadowInProcess()
Introduction.doc has some examples of the usage of this function.
NAME
DoSuperShadowInProcessAsync -- Front-end to DSM()
SYNOPSIS
result = DoSuperShadowInProcessAsync( process, object, class,
method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is identical to DoShadowInProcessAsync() except
that it invokes the method from the passed class' superclass. If the
passed class is NULL, then the method is invoked from the first
superclass of the object's class
DSM() is called in the following manner:
DSM(INVOKE_FIND_METHOD | INVOKE_WITH_PROCESS |
INVOKE_FORCE_ASYNC | INVOKE_FROM_SUPER,
&object)
INPUTS
OBJECT process; - the process object to invoke the
the method in.
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
void *result; - result from DSM()
RESULT
Result is dependent on the method invoked.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadow()
DoShadowHintProcess()
DoShadowInProcess()
DoShadowInProcessAsync()
Introduction.doc has some examples of the usage of this function.
NAME
HandleMessages -- Handle all incoming SHADOW messages, return when
^C is hit.
SYNOPSIS
HandleMessages()
FUNCTION
Handle all incoming messages in the ATTR_SHADOWPROCESS' jp_port and
jp_replyPort, and returns when a ^C is sensed.
This function actually invokes a METH_PROC_HANDLER on the current
process. The default PROCESS_CLASS defines the above behaviour,
you may define your own, of course.
As of SHADOW V, the function has been redefined as a macro and
resides in the shadow_proto.h file.
INPUTS
OUTPUTS
RESULT
When the method returns, there was a ^C sensed, or whatever
conditions that could cause one of your programs to exit their
METH_PROC_HANDLER method.
BUGS
none known.
NOTES
SEE ALSO
ParseShadowMessage()
JunkIPCMessage()
NAME
PreParseShadow -- Front-end to DSM()
SYNOPSIS
message = PreParseShadow( object, class, method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is another front-end to DSM().
This function is useful for obtaining a method invocation, and then
sending out the method at some later time and/or with some return
port that you manage. The latter is useful when trying to simulate
the way the Amiga's asynchronous message handling hass been
historically managed (SHADOW's asynchronous methods HAVE no
replyport...).
The following code is an example. Remember that the jp_port and the
jp_replyport are owned by SHADOW, and are not for your use!
Therefore, you will need to define your own replyport to receive
the replies of this message.
/*
* Create a message to handle a method invocation.
*/
message = PreParseShadow(object, NULL, METH_MINE_ALL_MINE,
DaffyDuck,
METHOD_END);
/*
* Set the replyport for this message to return to when method
* has finished.
*/
message->ipc_Msg.mn_ReplyPort = my_replyport;
/*
* The resource tracking required to keep our process alive until
* this message has been responded to. Note that there is a hack
* in the message creation code that leaves the last item blank
* for your usage -- this is what we now do!
*/
item = &message->ipc_Items[message->ipc_ItemCount - 1];
item->ii_Id = 'JOBJ';
item->ii_Ptr = UseObject(CurrentProcess());
item->ii_Flags = IPC_TRANSFER | IPC_NONSTANDARD;
/*
* Find destination port for method invocation.
*
* At this point we could just call ParseShadowMessage() to have
* the method performed in this task, and the reply put on our
* replyport, but that seems a bit ridiculous....
*/
destProcObject = GetMyDestinationProcessObject();
sp = (struct ShadowProcess *)
FindAttribute(destProcObject, ATTR_SHADOWPROCESS);
if (!(PutIPCMsg(sp->sp_port, message)))
JunkIPCMessage(message);
DropObject(destProcObject);
.
.
.
/*
* Now, when we receive the reply.
*/
message = GetIPCMessage(my_replyport);
/*
* Get the return value.
*/
return_value = message->ipc_Items[0].ii_Ptr;
/*
* Let the message know that it doesn't own the pointer anymore,
* we do.
*/
IpcItemTransfer(0, message);
/*
* Get rid of the message
*/
JunkIPCMessage(message);
/*
* Do something with the return value. Free it, DropObject() it,
* DropString() it, whatever when done using it.
*/
As with all of the DoShadow*() functions, this function checks that
a valid (non-NULL) object is sent , and returns NULL if the object
is NULL. if there is no valid class, class is set to
object->cob_class. If this is NULL, then the function returns NULL.
DSM() is called via:
DSM(INVOKE_FIND_METHOD | INVOKE_RETURN_MSG, &object);
INPUTS
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the selector string.
.
. <--- other arguments to your method
.
OUTPUTS
struct IPCMessage *result; - a message that can be sent via
PutIPCMessage(), or be parsed by
ParseShadowMessage(). If you later
decide not to use the message, it can
be discarded via the JunkIPCMessage()
call.
RESULT
A new IPC message is formed with all the necessary resource tracking
and all the necessary information to ensure that the method can be
called at some future point in time via the PutIPCMsg() or the
ParseShadowMessage() calls.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadow()
Introduction.doc has some examples of the usage of this function.
NAME
PreParseSuperShadow -- Front-end to DSM()
SYNOPSIS
message = PreParseSuperShadow( object, class, method, ..., METHOD_END)
d0 < args on stack >
FUNCTION
This function is identical to PreParseShadow() except that it
invokes the method from the passed class' superclass. If the passed
class is NULL, then the method is invoked from the first superclass
of the object's class
DSM() is called via:
DSM(INVOKE_FIND_METHOD | INVOKE_RETURN_MSG | INVOKE_FROM_SUPER,
&object);
INPUTS
OBJECT object; - the object to send the method to.
If NULL, function returns NULL
META class; - the first "class" to check for the
method. This allows you to send
a method to the superClass...
if NULL, class is set to
object->cob_class. If this is NULL,
then the function returns NULL.
char *method; - pointer to the method string.
.
. <--- other arguments to your method
.
OUTPUTS
struct IPCMessage *result; - a message that can be sent via
PutIPCMessage(), or be parsed by
ParseShadowMessage(). If you later
decide not to use the message, it can
be discarded via the JunkIPCMessage()
call.
RESULT
A new IPC message is formed with all the necessary resource tracking
and all the necessary information to ensure that the method can be
called at some future point in time via the PutIPCMsg() or the
ParseShadowMessage() calls.
BUGS
none known.
NOTES
SEE ALSO
DSM()
DoShadow()
PreParseShadow()
Introduction.doc has some examples of the usage of this function.
NAME
SprintfCallback -- sprintf callback for RawDoFmt. [shadow.lib]
SYNOPSIS
SprintfCallback(c, text);
d0 a3
FUNCTION
This function performs the parsing RawDoFmt requires for
an sprintf() type function.
Example:
/*
* Put the formatted string with the address of name2
* into the buffer.
*/
RawDoFmt("Object at: %lx", &name2, SprintfCallback, buffer);
INPUTS
char c; - the character to insert
char *text; - the string to insert it into.
OUTPUTS
a3 pointer is incremented
RESULT
BUGS
none known.
NOTES
SEE ALSO